package com.oocl.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.oocl.pojo.Customer;
import com.oocl.service.CustomerService;

public class CustomerServiceImpl implements CustomerService{

	private static List<Customer> customers= new ArrayList<Customer>();
	
	@Override
	public synchronized Customer addCustomer(Customer c) {
			String id = UUID.randomUUID().toString();
			c.setId(id);
			customers.add(c);
			return c;
	}

	@Override
	public boolean deleteCustomer(String id) {
		for (int i = 0; i < customers.size(); i++) {
			String index = customers.get(i).getId();
			if(id.equals(index)){
				customers.remove(i);
				return true;
			}
		}
		return false;
	}

	@Override
	public boolean updateCustomer(Customer c) {
		return false;
	}

	@Override
	public List<Customer> listCustomer() {
		return customers;
	}

}
